package cn.dragon.eatingfish;

import javax.swing.*;
import java.awt.*;
import java.util.Timer;
import java.util.TimerTask;

public class TipWindow extends JPanel {

    public TipWindow() {

    }

    public void paintIntroduce() {
        JDialog tipLog = new JDialog();
        tipLog.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
        tipLog.setSize(WIDTH + 19, HEIGHT + 48);
        tipLog.setLocation(1510, 150);
        tipLog.setVisible(true);
        tipLog.setIconImage(Images.logo.getImage());
        // 保证窗口改变图片能显示
        tipLog.setResizable(false);
        this.setFocusable(true);
        tipLog.add(this);
        this.action();
        tipLog.setSize(300, 753);
    }


    public void action() {
        java.util.Timer timer = new Timer(); //定时器对象
        int interval = 10; //定时间隔(以毫秒为单位)
        timer.schedule(new TimerTask() {
            public void run() { //定时干的事(每10毫秒自动执行)
                repaint(); //重画(重新调用paint()方法)-----不要求掌握
            }
        }, interval, interval); //定时计划表
    }

    @Override
    public void paint(Graphics g) {
        Images.tipWindow.paintIcon(null, g, 0, 0);
        if (World.getMajorFish().getLevel() >= 1) {
            Images.fish_1_L.paintIcon(null, g, 100, 150);
        }
        if (World.getMajorFish().getLevel() >= 2) {
            Images.fish_2_L.paintIcon(null, g, 100, 210);
        }
        if (World.getMajorFish().getLevel() >= 3) {
            Images.fish_3_L.paintIcon(null, g, 100, 285);
        }
        if (World.getMajorFish().getLevel() >= 4) {
            Images.fish_4_L.paintIcon(null, g, 80, 400);
        }
        if (World.getMajorFish().getLevel() >= 5) {
            Images.fish_5_L.paintIcon(null, g, 70, 480);
        }
        if (World.getMajorFish().getLevel() >= 6) {
            Images.fish_6_L.paintIcon(null, g, 0, 565);
        }
    }
}
